package com.migu.contacts.main.my;

import static com.migu.contacts.net.Service.API;

import android.util.Log;
import android.view.View;

import com.frank.libandroid.BaseActivity;
import com.frank.libandroid.BaseAdapter;
import com.frank.libandroid.butterknife.BindAdapter;
import com.frank.libandroid.butterknife.OnClick;
import com.migu.contacts.R;
import com.migu.contacts.bean.GuideDescBean;
import com.migu.contacts.databinding.ActivityInstructionBinding;
import com.migu.contacts.databinding.ItemInstructionBinding;
import com.migu.contacts.net.ResultCallback;

import java.util.List;

public class InstructionActivity extends BaseActivity<ActivityInstructionBinding> {

    @BindAdapter(R.id.recyclerView)
    BaseAdapter<ItemInstructionBinding, GuideDescBean> adapter = new BaseAdapter<ItemInstructionBinding, GuideDescBean>() {
        @OnClick(R.id.click)
        public void click(ItemInstructionBinding binding) {
            binding.click.setSelected(!binding.click.isSelected());
            if (binding.click.isSelected()) {
                binding.content.setVisibility(View.VISIBLE);
            } else {
                binding.content.setVisibility(View.GONE);
            }
        }
    };

    @Override
    protected void initData() {
        super.initData();
//        List<Bean> list = new ArrayList<>();
//        list.add(new Bean("如何删除人脉卡", ""));
//        list.add(new Bean("如何自定义标签", ""));
//        list.add(new Bean("如何删除分组", ""));
//        adapter.setData(list);
        API.commonDocumentGuide().enqueue(new ResultCallback<List<GuideDescBean>>() {
            @Override
            protected void onSuccess(List<GuideDescBean> guideDescBeans) {
                Log.d(TAG, "onSuccess() called with: guideDescBeans = [" + guideDescBeans + "]");
                adapter.setData(guideDescBeans);
            }
        });
    }
}